package com.app.notification;

import androidx.appcompat.app.AppCompatActivity;

import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.RemoteViews;

import com.zndroid.notification.Notifier;
import com.zndroid.notification.assist.IconUtilities;
import com.zndroid.notification.box.Trumpet;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void common(View view) {
        Intent intent = new Intent(this, SecondActivity.class);
        intent.putExtra("params", "im params from main activity");

        Intent deleteIntent = new Intent();
        deleteIntent.setClass(this, DeleteReceiver.class);
        deleteIntent.setAction("msg_delete");


        Trumpet trumpet = new Trumpet.Builder()
                .setId(2021)
                .setSmallIcon(R.mipmap.icon_small)
                .setBigIcon(R.mipmap.ic_launcher)
                .setBigPicture(new IconUtilities(this).createIconBitmap(getResources().getDrawable(R.drawable.ic_launcher_background)))
                .setMessage("hahahahahahahahahahahahahahahahahahahahahahahahahahahahaahahhahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaahahhahaha")
                .setTitle("title")
                .setChannelId("channel1")
                .setChannelName("common channel")
                .withLight()
                .withSound(Settings.System.DEFAULT_RINGTONE_URI)
                .withVibrate()
                .setActionPending(PendingIntent.getActivity(MainActivity.this, 1111111, intent, PendingIntent.FLAG_UPDATE_CURRENT))
                .setDeletePending(PendingIntent.getBroadcast(MainActivity.this, 222222, deleteIntent, 0))
                .build();

        Notifier.with(this)
                .holdTrumpet(trumpet)
                .show();
    }

    int i = 1;
    public void diffId(View view) {
        Trumpet trumpet = new Trumpet.Builder()
                .setId(i++)
                .setChannelId("channel3")
                .setChannelName("diff id channel")
                .setSmallIcon(R.mipmap.icon_small)
                .setBigIcon(R.mipmap.ic_launcher)
                .setBigPicture(new IconUtilities(this).createIconBitmap(getResources().getDrawable(R.drawable.ic_launcher_background)))
                .setMessage("get message=" + i)
                .setTitle("title")
                .withLight()
                .withSound()
                .withVibrate()
                .build();

        Notifier.with(this)
                .holdTrumpet(trumpet)
                .show();
    }

    public void customUI(View view) {
        RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.layout_remote_view);
        remoteViews.setTextViewText(R.id.text, "Custom Text");
        remoteViews.setTextViewText(R.id.btn, "Custom Button");
        remoteViews.setImageViewResource(com.zndroid.notification.R.id.image, R.mipmap.icon_small);

        Trumpet trumpet = new Trumpet.Builder()
                .setId(2021)
                .setChannelId("channel2")
                .setChannelName("custom UI channel")
                .setSmallIcon(R.mipmap.icon_small)
                .setBigIcon(R.mipmap.ic_launcher)
                .setBigPicture(new IconUtilities(this).createIconBitmap(getResources().getDrawable(R.drawable.ic_launcher_background)))
                .setMessage("uiuiui")
                .setTitle("title")
                .withLight()
                .withSound()
                .withVibrate()
                .setRemoteViews(remoteViews)
                .build();

        Notifier.with(this)
                .holdTrumpet(trumpet)
                .show();
    }
}